import{d as k,aM as y,k as s,O as d,aN as z,I as F,b as L,o as _,a as T,ar as H,F as O,r as $,aO as b,u as N,ag as q}from"./DrFvzlh8agutd.js";const A=k({__name:"app-list-virtual",props:{data:{},margin:{},itemSize:{},poolBuffer:{}},setup(x){const g=x,{data:o,poolBuffer:r,itemSize:t}=y(g),a=s(null),i=g.margin??0,u=Math.ceil(r.value/10)*2,c=s(o.value.length*t.value+2*i),v=s(0),f=s(0),m=s(i);let M=0,p=!1,S=0;function h(){if(!a.value)return;const l=a.value.scrollLeft;l!==S&&(S=l,q.emit("updateScroll",l)),!p&&(p=!0,requestAnimationFrame(()=>{if(p=!1,!a.value)return;const e=[];e[0]=Math.floor(a.value.scrollTop/t.value)-Math.floor(r.value/2),e[0]=Math.max(e[0],0),e[1]=e[0]+Math.floor(a.value.clientHeight/t.value)+r.value,e[1]=Math.min(Math.ceil(e[1]/u)*u,o.value.length),e[0]=Math.max(Math.floor(e[0]/u)*u,0),v.value=e[0],f.value=e[1],m.value=e[0]*t.value+i}))}return d(o,l=>{c.value=l.length*t.value}),d(t,l=>{c.value=o.value.length*l}),d(()=>o.value.length,h),z("listScrollTop",()=>{a.value&&(a.value.scrollTop=0),h()}),F(()=>{if(!a.value)return;M=a.value.clientHeight;const n=[0,Math.ceil(M/t.value)+r.value];v.value=n[0],f.value=n[0]+n[1]}),(l,e)=>(_(),L("div",{ref_key:"root",ref:a,class:"app-list-scroll",onScrollPassive:h},[T("div",{style:H(`height: ${c.value}px; padding-top: ${m.value}px`)},[(_(!0),L(O,null,$(N(o).slice(v.value,f.value),(n,B)=>b(l.$slots,"default",{key:n._id,item:n,index:B})),128))],4)],544))}});export{A as _};